package cn.choujay.tlias.service.impl;


import cn.choujay.tlias.domain.Emp;
import cn.choujay.tlias.mapper.EmpMapper;
import cn.choujay.tlias.service.EmpService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.Calendar;
import java.util.Date;
import java.util.List;

/**
 * @author Ye
 * @description 针对表【emp(员工表)】的数据库操作Service实现
 * @createDate 2023-05-20 20:52:38
 */
@Service
public class EmpServiceImpl implements EmpService {
    @Resource
    private EmpMapper empMapper;

    @Override
    public Emp getByIdEmp(String username) {
        return empMapper.getByIdEmp(username);
    }
    @Override
    public List<Emp> getAllEmp() {
        return empMapper.getAllEmp();
    }

    @Override
    public Boolean addEmp(Emp emp) {

        //2023-05-19 22:35:13
        //2023-05-19 22:35:13
        Date now = Calendar.getInstance().getTime();
        emp.setCreateTime(now);
        emp.setUpdateTime(now);
//        emp.setCreateTime();
//        emp.setUpdateTime();
        return empMapper.addEmp(emp);


    }

    @Override
    public Boolean updateEmp(Emp emp) {
        Date now = Calendar.getInstance().getTime();
        emp.setUpdateTime(now);
        return empMapper.updateEmp(emp);
    }

    @Override
    public List<Emp> Search(String name, Integer gender, Date start, Date end) {
        return empMapper.Search(name, gender, start, end);

    }

    @Override
    public Boolean deleteEmp(Integer[] ids) {
        return empMapper.deleteEmp(ids);
    }
}
